package com.umeox.iqibla.custom_tasbih.base

import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import android.content.Intent
import com.umeox.moto.common.log.Logger
import com.umeox.watch.moto.dataservice.DataProvider
import com.umeox.watch.moto.dataservice.constants.Constants

/**
 * Created by Rambo 2021/8/18
 * Describe:
 */
class BaseApp : Application() {

    companion object {
        private var appContext: Context? = null
        fun getContext(): Context {
            return appContext as Context
        }

        @SuppressLint("UnsafeImplicitIntentLaunch", "WrongConstant")
        fun schedulePrayerTimeAlarm() {
            Logger.i("发送广播重置闹钟")
            val intent =
                Intent(Constants.ACTION_UPDATED_TASK_LIST)
            intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES or Intent.FLAG_RECEIVER_FOREGROUND or Constants.FLAG_RECEIVER_INCLUDE_BACKGROUND)
            appContext?.sendBroadcast(intent)
        }

    }



    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        appContext = this
    }

    override fun onCreate() {
        super.onCreate()
        DataProvider.initialize(this)
    }
}